﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;

namespace QSTOOL.Codes
{
    public class Command
    {
        public string command { get; set; }
        public string detail { get; set; }
        public string source { get; set; }
        public string target { get; set; }
        public string description { get; set; }
        public string guid { get; set; }
        public const string COPY = "COPY";
        public const string DELETE = "DELETE";
        public const string DB2 = "DB2";
        public const string DBF = "DBF";
        public const string FTP = "FTP";
        public const string CHECK = "CHECK";

        public Command(XmlNode node)
        {
            if (node != null)
            {
                if (node.Attributes[Attribute.COMMAND] != null)
                {
                    this.command = node.Attributes["COMMAND"].Value;
                }

                if (node.Attributes[Attribute.DETAIL] != null)
                {
                    this.detail = node.Attributes["DETAIL"].Value;
                }

                if (node.Attributes[Attribute.SOURCE] != null)
                {
                    this.source = node.Attributes["SOURCE"].Value;
                }

                if (node.Attributes[Attribute.TARGET] != null)
                {
                    this.target = node.Attributes["TARGET"].Value;
                }

                if (node.Attributes[Attribute.DESCRIPTION] != null)
                {
                    this.description = node.Attributes["DESCRIPTION"].Value;
                }

                if (node.Attributes[Attribute.GUID] != null)
                {
                    this.guid = node.Attributes["GUID"].Value;
                }
            }
        }

        public Command()
        { 
        
        }
    }
}
